#include <string>
#include <vector>
#include <algorithm>
using namespace std;
/*
 * @lc app=leetcode.cn id=179 lang=cpp
 *
 * [179] 最大数
 */

// @lc code=start
class Solution {
public:
    static bool compare(string a, string b) {
        return a + b > b + a;
    }
    string largestNumber(vector<int>& nums) {
        vector<string> snums;
        for (auto x: nums) snums.push_back(to_string(x));
        sort(snums.begin(), snums.end(), compare);
        stringstream res;
        if (snums[0][0] == '0') return "0";
        for (int i = 0; i < snums.size(); i++) {
            res << snums[i];
        }
        return res.str();
    }
};
// @lc code=end

